package com.mygdx.game.desktop.demo;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Bezier;
import com.badlogic.gdx.math.Vector2;

/**
 * .图形测试类
 * @author Administrator
 *
 */
public class ShapeTestGame extends Game{

	protected Bezier<Vector2> bezier;

    float t;

    float speed = 0.1f;

    final Vector2 tmpV = new Vector2();

    ShapeRenderer shapeRenderer;

	@Override
	public void create() {
        shapeRenderer = new ShapeRenderer();
        bezier = new Bezier<>(new Vector2(100, 100), new Vector2(500, 500));
		
	}
	
	public void render() {
		Gdx.gl.glClearColor(0.7f, 0.7f, 0.7f, 1);
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        if (tmpV.x <= Gdx.graphics.getWidth()-200 || tmpV.y <= Gdx.graphics.getHeight()-200) {
            t += speed * Gdx.graphics.getDeltaTime();
            bezier.valueAt(tmpV, t);
        }

        Gdx.app.error("DANNY", "tmpV.x is " + tmpV.x + " tmpV.y is " + tmpV.y);

        shapeRenderer.begin(ShapeRenderer.ShapeType.Line);

        shapeRenderer.rectLine(100, 100, tmpV.x, tmpV.y, 10);

        shapeRenderer.end();

	}
	
	public static void main(String[] args) {
        new LwjglApplication(new ShapeTestGame());
    }
}